//
//  GTGiftDetailHeaderView.m
//  GiftTalk
//
//  Created by Wan on 16/3/28.
//  Copyright © 2016年 Wan. All rights reserved.
//  搜索礼物详细页头部视图

#import "GTGiftDetailHeaderView.h"
#import "GTSearchGift.h"
#import "GTPageScrollView.h"

#define GTGiftDetailHeaderMargin 10.0;

@interface GTGiftDetailHeaderView ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;

/** 辅助属性 - 礼物基本信息容器 */
@property (weak, nonatomic) IBOutlet UIView *headerInfoContainer;
@end

@implementation GTGiftDetailHeaderView

- (void)awakeFromNib
{
    self.descLabel.preferredMaxLayoutWidth = GTScreenW - 20;
    self.autoresizingMask = UIViewAutoresizingNone;
}

+ (instancetype)giftDetailHeader
{
    return [self viewFromXib];
}

- (void)setGiftItem:(GTSearchGift *)giftItem
{
    _giftItem = giftItem;
    self.pageScrollView.imageURLStrings = giftItem.image_urls;
    self.nameLabel.text = giftItem.name;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%@",giftItem.price];
    self.descLabel.text = giftItem.giftDescription;
    
    self.width = GTScreenW;
    [self layoutIfNeeded];
    /** 坐标系转换 */
    self.giftItem.detailHeaderHeight = CGRectGetMaxY(self.headerInfoContainer.frame) + CGRectGetMaxY(self.descLabel.frame);
//    2 * GTGiftDetailHeaderMargin;
//    CGRectGetMaxY([self.pageScrollView convertRect:self.headerInfoContainer.bounds fromView:self.descLabel]);
    
//    CGRectGetMaxY(self.headerInfoContainer.frame) + CGRectGetMaxY(self.descLabel.frame) + 10;
//    GTLog(@"%f==",self.giftItem.detailHeaderHeight );
}

- (void)setFrame:(CGRect)frame
{
    CGFloat margin = 10;
    frame.size.height -= margin;
    
    [super setFrame:frame];
}

@end
